<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
 <head>
  <meta http-equiv="content-type" content="text/html; charset=UTF-8">
  <title>Date Formats</title>
<link media="all" rel="stylesheet" type="text/css" href="styles/03e73060321a0a848018724a6c83de7f-theme-base.css" />
<link media="all" rel="stylesheet" type="text/css" href="styles/03e73060321a0a848018724a6c83de7f-theme-medium.css" />

 </head>
 <body class="docs"><div class="navbar navbar-fixed-top">
  <div class="navbar-inner clearfix">
    <ul class="nav" style="width: 100%">
      <li style="float: left;"><a href="datetime.formats.time.html">« Time Formats</a></li>
      <li style="float: right;"><a href="datetime.formats.compound.html">Compound Formats »</a></li>
    </ul>
  </div>
</div>
<div id="breadcrumbs" class="clearfix">
  <ul class="breadcrumbs-container">
    <li><a href="index.html">PHP Manual</a></li>
    <li><a href="datetime.formats.html">Supported Date and Time Formats</a></li>
    <li>Date Formats</li>
  </ul>
</div>
<div id="layout">
  <div id="layout-content"><div id="datetime.formats.date" class="sect1">
  <h2 class="title">Date Formats</h2>
  
  <p class="para">
   This page describes the different date formats that the
   <span class="classname"><a href="class.datetimeimmutable.html" class="classname">DateTimeImmutable</a></span>, <span class="classname"><a href="class.datetime.html" class="classname">DateTime</a></span>,
   <span class="function"><a href="function.date-create.html" class="function">date_create()</a></span>,
   <span class="function"><a href="function.date-create-immutable.html" class="function">date_create_immutable()</a></span>, and
   <span class="function"><a href="function.strtotime.html" class="function">strtotime()</a></span> parser understands.
  </p>
  
  <table class="doctable table">
   <caption><strong>Used Symbols</strong></caption>
   
    <thead>
     <tr>
      <th>Description</th>
      <th>Format</th>
      <th>Examples</th>
     </tr>

    </thead>

    <tbody class="tbody">
     <tr>
      <td><code class="literal">daysuf</code></td>
      <td>&quot;st&quot; | &quot;nd&quot; | &quot;rd&quot; | &quot;th&quot;</td>
      <td class="empty">&nbsp;</td>
     </tr>

     <tr>
      <td><code class="literal">dd</code></td>
      <td>([0-2]?[0-9] | &quot;3&quot;[01]) <code class="literal">daysuf</code>?</td>
      <td>&quot;7th&quot;, &quot;22nd&quot;, &quot;31&quot;</td>
     </tr>

     <tr>
      <td><code class="literal">DD</code></td>
      <td>&quot;0&quot; [0-9] | [1-2][0-9] | &quot;3&quot; [01]</td>
      <td>&quot;07&quot;, &quot;31&quot;</td>
     </tr>

     <tr>
      <td><code class="literal">m</code></td>
      <td>&#039;january&#039; | &#039;february&#039; | &#039;march&#039; | &#039;april&#039; | &#039;may&#039; | &#039;june&#039; |
       &#039;july&#039; | &#039;august&#039; | &#039;september&#039; | &#039;october&#039; | &#039;november&#039; | &#039;december&#039; |
       &#039;jan&#039; | &#039;feb&#039; | &#039;mar&#039; | &#039;apr&#039; | &#039;may&#039; | &#039;jun&#039; | &#039;jul&#039; | &#039;aug&#039; | &#039;sep&#039; |
       &#039;sept&#039; | &#039;oct&#039; | &#039;nov&#039; | &#039;dec&#039; | &quot;I&quot; | &quot;II&quot; | &quot;III&quot; | &quot;IV&quot; | &quot;V&quot; | &quot;VI&quot;
       | &quot;VII&quot; | &quot;VIII&quot; | &quot;IX&quot; | &quot;X&quot; | &quot;XI&quot; | &quot;XII&quot;</td>
      <td class="empty">&nbsp;</td>
     </tr>

     <tr>
      <td><code class="literal">M</code></td>
      <td>&#039;jan&#039; | &#039;feb&#039; | &#039;mar&#039; | &#039;apr&#039; | &#039;may&#039; | &#039;jun&#039; | &#039;jul&#039; | &#039;aug&#039; |
       &#039;sep&#039; | &#039;sept&#039; | &#039;oct&#039; | &#039;nov&#039; | &#039;dec&#039;</td>
      <td class="empty">&nbsp;</td>
     </tr>

     <tr>
      <td><code class="literal">mm</code></td>
      <td>&quot;0&quot;? [0-9] | &quot;1&quot;[0-2]</td>
      <td>&quot;0&quot;, &quot;04&quot;, &quot;7&quot;, &quot;12&quot;</td>
     </tr>

     <tr>
      <td><code class="literal">MM</code></td>
      <td>&quot;0&quot; [0-9] | &quot;1&quot;[0-2]</td>
      <td>&quot;00&quot;, &quot;04&quot;, &quot;07&quot;, &quot;12&quot;</td>
     </tr>

     <tr>
      <td><code class="literal">y</code></td>
      <td>[0-9]{1,4}</td>
      <td>&quot;00&quot;, &quot;78&quot;, &quot;08&quot;, &quot;8&quot;, &quot;2008&quot;</td>
     </tr>

     <tr>
      <td><code class="literal">yy</code></td>
      <td>[0-9]{2}</td>
      <td>&quot;00&quot;, &quot;08&quot;, &quot;78&quot;</td>
     </tr>

     <tr>
      <td><code class="literal">YY</code></td>
      <td>[0-9]{4}</td>
      <td>&quot;2000&quot;, &quot;2008&quot;, &quot;1978&quot;</td>
     </tr>

     <tr>
      <td><code class="literal">YYY</code></td>
      <td>[0-9]{5,19}</td>
      <td>&quot;81412&quot;, &quot;20192&quot;</td>
     </tr>

    </tbody>
   
  </table>

  
  <table class="doctable table">
   <caption><strong>Localized Notations</strong></caption>
   
    <thead>
     <tr>
      <th>Description</th>
      <th>Format</th>
      <th>Examples</th>
     </tr>

    </thead>

    <tbody class="tbody">
     <tr>
      <td>American month and day</td>
      <td><code class="literal">mm</code> &quot;/&quot; <code class="literal">dd</code></td>
      <td>&quot;5/12&quot;, &quot;10/27&quot;</td>
     </tr>

     <tr>
      <td>American month, day and year</td>
      <td><code class="literal">mm</code> &quot;/&quot; <code class="literal">dd</code> &quot;/&quot; <code class="literal">y</code></td>
      <td>&quot;12/22/78&quot;, &quot;1/17/2006&quot;, &quot;1/17/6&quot;</td>
     </tr>

     <tr>
      <td>Four digit year, month and day with slashes</td>
      <td><code class="literal">YY</code> &quot;/&quot; <code class="literal">mm</code> &quot;/&quot; <code class="literal">dd</code></td>
      <td>&quot;2008/6/30&quot;, &quot;1978/12/22&quot;</td>
     </tr>

     <tr>
      <td>Four digit year and month (GNU)</td>
      <td><code class="literal">YY</code> &quot;-&quot; <code class="literal">mm</code></td>
      <td>&quot;2008-6&quot;, &quot;2008-06&quot;, &quot;1978-12&quot;</td>
     </tr>

     <tr>
      <td>Year, month and day with dashes</td>
      <td><code class="literal">y</code> &quot;-&quot; <code class="literal">mm</code> &quot;-&quot; <code class="literal">dd</code></td>
      <td>&quot;2008-6-30&quot;, &quot;78-12-22&quot;, &quot;8-6-21&quot;</td>
     </tr>

     <tr>
      <td>Day, month and four digit year, with dots, tabs or dashes</td>
      <td><code class="literal">dd</code> [.\t-] <code class="literal">mm</code> [.-] <code class="literal">YY</code></td>
      <td>&quot;30-6-2008&quot;, &quot;22.12.1978&quot;</td>
     </tr>

     <tr>
      <td>Day, month and two digit year, with dots or tabs</td>
      <td><code class="literal">dd</code> [.\t] <code class="literal">mm</code> &quot;.&quot; <code class="literal">yy</code></td>
      <td>&quot;30.6.08&quot;, &quot;22\t12.78&quot;</td>
     </tr>

     <tr>
      <td>Day, textual month and year</td>
      <td><code class="literal">dd</code> ([ \t.-])* <code class="literal">m</code> ([ \t.-])* <code class="literal">y</code></td>
      <td>&quot;30-June 2008&quot;, &quot;22DEC78&quot;, &quot;14 III 1879&quot;</td>
     </tr>

     <tr>
      <td>Textual month and four digit year (Day reset to 1)</td>
      <td><code class="literal">m</code> ([ \t.-])* <code class="literal">YY</code></td>
      <td>&quot;June 2008&quot;, &quot;DEC1978&quot;, &quot;March 1879&quot;</td>
     </tr>

     <tr>
      <td>Four digit year and textual month (Day reset to 1)</td>
      <td><code class="literal">YY</code> ([ \t.-])* <code class="literal">m</code></td>
      <td>&quot;2008 June&quot;, &quot;1978-XII&quot;, &quot;1879.MArCH&quot;</td>
     </tr>

     <tr>
      <td>Textual month, day and year</td>
      <td><code class="literal">m</code> ([ .\t-])* <code class="literal">dd</code> [,.stndrh\t ]+ <code class="literal">y</code></td>
      <td>&quot;July 1st, 2008&quot;, &quot;April 17, 1790&quot;, &quot;May.9,78&quot;</td>
     </tr>

     <tr>
      <td>Textual month and day</td>
      <td><code class="literal">m</code> ([ .\t-])* <code class="literal">dd</code> [,.stndrh\t ]*</td>
      <td>&quot;July 1st,&quot;, &quot;Apr 17&quot;, &quot;May.9&quot;</td>
     </tr>

     <tr>
      <td>Day and textual month</td>
      <td><code class="literal">dd</code> ([ .\t-])* <code class="literal">m</code></td>
      <td>&quot;1 July&quot;, &quot;17 Apr&quot;, &quot;9.May&quot;</td>
     </tr>

     <tr>
      <td>Month abbreviation, day and year</td>
      <td><code class="literal">M</code> &quot;-&quot; <code class="literal">DD</code> &quot;-&quot; <code class="literal">y</code></td>
      <td>&quot;May-09-78&quot;, &quot;Apr-17-1790&quot;</td>
     </tr>

     <tr>
      <td>Year, month abbreviation and day</td>
      <td><code class="literal">y</code> &quot;-&quot; <code class="literal">M</code> &quot;-&quot; <code class="literal">DD</code></td>
      <td>&quot;78-Dec-22&quot;, &quot;1814-MAY-17&quot;</td>
     </tr>

     <tr>
      <td>Year (and just the year)</td>
      <td><code class="literal">YY</code></td>
      <td>&quot;1978&quot;, &quot;2008&quot;</td>
     </tr>

     <tr>
      <td>Year (expanded, 5-19 digits with sign)</td>
      <td>[+-] <code class="literal">YYY</code></td>
      <td>&quot;-81120&quot;, &quot;+20192&quot;</td>
     </tr>

     <tr>
      <td>Textual month (and just the month)</td>
      <td><code class="literal">m</code></td>
      <td>&quot;March&quot;, &quot;jun&quot;, &quot;DEC&quot;</td>
     </tr>

    </tbody>
   
  </table>

  
  <table class="doctable table">
   <caption><strong>ISO8601 Notations</strong></caption>
   
    <thead>
     <tr>
      <th>Description</th>
      <th>Format</th>
      <th>Examples</th>
     </tr>

    </thead>

    <tbody class="tbody">
     <tr>
      <td>Eight digit year, month and day</td>
      <td><code class="literal">YY</code> <code class="literal">MM</code> <code class="literal">DD</code></td>
      <td>&quot;15810726&quot;, &quot;19780417&quot;, &quot;18140517&quot;</td>
     </tr>

     <tr>
      <td>Four digit year, month and day with slashes</td>
      <td><code class="literal">YY</code> &quot;/&quot; <code class="literal">MM</code> &quot;/&quot; <code class="literal">DD</code></td>
      <td>&quot;2008/06/30&quot;, &quot;1978/12/22&quot;</td>
     </tr>

     <tr>
      <td>Two digit year, month and day with dashes</td>
      <td><code class="literal">yy</code> &quot;-&quot; <code class="literal">MM</code> &quot;-&quot; <code class="literal">DD</code></td>
      <td>&quot;08-06-30&quot;, &quot;78-12-22&quot;</td>
     </tr>

     <tr>
      <td>Four digit year with optional sign, month and day</td>
      <td>[+-]? <code class="literal">YY</code> &quot;-&quot; <code class="literal">MM</code> &quot;-&quot; <code class="literal">DD</code></td>
      <td>&quot;-0002-07-26&quot;, &quot;+1978-04-17&quot;, &quot;1814-05-17&quot;</td>
     </tr>

     <tr>
      <td>Five+ digit year with required sign, month and day</td>
      <td>[+-] <code class="literal">YYY</code> &quot;-&quot; <code class="literal">MM</code> &quot;-&quot; <code class="literal">DD</code></td>
      <td>&quot;-81120-02-26&quot;, &quot;+20192-04-17&quot;</td>
     </tr>

    </tbody>
   
  </table>

  
  <blockquote class="note"><p><strong class="note">注意</strong>: 
   <p class="para">
    For the <code class="literal">y</code> and <code class="literal">yy</code>
    formats, years below 100 are handled in a special way when the
    <code class="literal">y</code> or <code class="literal">yy</code> symbol is used.
    If the year falls in the range 0 (inclusive) to 69 (inclusive),
    2000 is added. If the year falls in the range 70 (inclusive) to
    99 (inclusive) then 1900 is added. This means that &quot;00-01-01&quot; is
    interpreted as &quot;2000-01-01&quot;.
   </p>
  </p></blockquote>
  
  <blockquote class="note"><p><strong class="note">注意</strong>: 
   <p class="para">
    The &quot;Day, month and two digit year, with dots or tabs&quot; format
    (<code class="literal">dd</code> [.\t] <code class="literal">mm</code> &quot;.&quot;
    <code class="literal">yy</code>) only works for the year values 61 (inclusive)
    to 99 (inclusive) - outside those years the <em class="emphasis">time
    format</em> &quot;<code class="literal">HH</code> [.:] <code class="literal">MM</code>
    [.:] <code class="literal">SS</code>&quot; has precedence.
   </p>
  </p></blockquote>
  
  <blockquote class="note"><p><strong class="note">注意</strong>: 
   <p class="para">
    The &quot;Year (and just the year)&quot; format only works if a time string
    has already been found -- otherwise this format is recognised as
    <code class="literal">HH</code> <code class="literal">MM</code>.
   </p>
  </p></blockquote>
  
  <div class="caution"><strong class="caution">警告</strong>
   <p class="para">
    It is possible to over- and underflow the <code class="literal">dd</code> and
    <code class="literal">DD</code> format. Day 0 means the last day of previous
    month, whereas overflows count into the next month. This makes
    &quot;2008-08-00&quot; equivalent to &quot;2008-07-31&quot; and &quot;2008-06-31&quot; equivalent
    to &quot;2008-07-01&quot; (June only has 30 days).
   </p>
   <p class="para">
    Note that the day range is restricted to 0-31 as indicated
    by the regular expression above. Thus &quot;2008-06-32&quot; is not a valid date
    string, for instance.
   </p>
   <p class="para">
    It is also possible to underflow the <code class="literal">mm</code> and
    <code class="literal">MM</code> formats with the value 0. A month value of
    0 means December of the previous year. As example &quot;2008-00-22&quot; is
    equivalent to &quot;2007-12-22&quot;.
   </p>
   <p class="para">
    If you combine the previous two facts and underflow both the day and
    the month, the following happens: &quot;2008-00-00&quot; first gets converted
    to &quot;2007-12-00&quot; which then gets converted to &quot;2007-11-30&quot;. This also
    happens with the string &quot;0000-00-00&quot;, which gets transformed into
    &quot;-0001-11-30&quot; (the year -1 in the ISO 8601 calendar, which is 2 BC
    in the proleptic Gregorian calendar).
   </p>
  </div>
 </div></div></div></body></html>